package com.iot.north.app.demo.invoke.controller;

import com.iot.north.app.demo.domain.ResultDTO;
import com.iot.north.app.demo.invoke.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 基于API调用的接口开发
 *
 * <p>注意：此处为重新自定义接口的开发，只是为开发者提供开发思路，实际调用API接口在deviceService中完成。
 */
@Slf4j
@RestController
@RequestMapping("/invoke")
public class InvokeController {
  @Autowired private DeviceService deviceService;

  /** 新增设备接口 */
  @PostMapping("/addDevice")
  public ResultDTO addDevice(
      @RequestParam(value = "pk") String pk,
      @RequestParam(value = "devId") String devId,
      @RequestParam(value = "name") String name) {
    return deviceService.addDevice(pk, devId, name);
  }
}
